const express = require('express');
const router = express.Router();
const { getToken } = require('../token/token');
const fs = require('fs');
router.get('/', (req, res) => {
    const tokenResult = getToken(req.headers.authorization);
    if (!tokenResult.boolean) {
        return res.status(405).send(tokenResult.msg);
    }
    const MapFilePath = './src/MapList/ChinaMap.json';
    const stream = fs.createReadStream(MapFilePath);
    res.setHeader('Content-Type', 'application/json');
    stream.pipe(res);
    stream.on('error', (err) => {
        console.error('读取文件错误:', err);
        return res.status(500).json({ error: '服务器错误，无法解析JSON文件' });
    });
});
module.exports = router;